package com.itheima.Demo;

import sun.security.util.Length;

import java.util.ArrayList;
import java.util.logging.Filter;

public class Tesk4 {
    public static void main(String[] args) {
        ArrayList<String> list1 = new ArrayList<>();
        list1.add("张三");
        list1.add("张三丰");
        list1.add("张无忌");
        list1.add("刘无求");
        list1.add("沈万三");
        System.out.println(list1);

        ArrayList<String> list2 = new ArrayList<>();
        for (String s : list1) {
            if(s.startsWith("张")){
                list2.add(s);
            }
        }
        ArrayList<String> list3 = new ArrayList<>();
        for (String s : list2) {
            if(s.length() == 3){
                list3.add(s);
            }
        }
        System.out.println(list3);
        for (String s : list3) {
            System.out.println(s);
        }
        System.out.println("===============");

        list1.stream().filter(s -> s.startsWith("张"))
                .filter(s -> s.length() == 3)
                .forEach(s -> System.out.println(s));

    }
}
